package com.cheer.service.impl;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cheer.dao.MallOrderFinishDao;
import com.cheer.entity.MallOrderFinishEntity;
import com.cheer.service.MallOrderFinishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("mallOrderFinishService")
public class MallOrderFinishServiceImpl extends ServiceImpl<MallOrderFinishDao, MallOrderFinishEntity> implements MallOrderFinishService {

    @Autowired
    private MallOrderFinishDao mallOrderFinishDao;

    @Override
    public List<MallOrderFinishEntity> listToFinishOrder() {
        return mallOrderFinishDao.selectListByFinishTime();
    }

    @Override
    public void updateFinishTimeByOrderId(Long orderId, DateTime finishTime) {
        MallOrderFinishEntity orderFinish = new MallOrderFinishEntity()
                .setFinishTime(finishTime);
        mallOrderFinishDao.updateByOrderId(orderId, orderFinish);
    }

    @Override
    public void deleteByOrderId(Long orderId) {
        mallOrderFinishDao.deleteByOrderId(orderId);
    }
}